home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Video Toaster 4.3
/
Video Toaster v4.3.iso
/
4.2
/
arexx
/
modeler
/
cage.lwm
< prev
next >
Wrap
Text File
|
1998-04-16
|
3KB
|
129 lines
/* CMD: Spline Cage
*
* Generate a cylindrical spline cage for starting point in spline modeling.
*/
call addlib "LWModelerARexx.port", 0
MATHLIB="rexxmathlib.library"
IF POS(MATHLIB , SHOW('L')) = 0 THEN
IF ~ADDLIB(MATHLIB , 0 , -30 , 0) THEN DO
call notify(1,"!Can't find "MATHLIB)
exit
END
sysnam = 'Spline Cage'
filnam = 'T:cage.state'
version = 'Spline Cage v1.0'
/* Setup state. Read stored one, if any.
*/
seg = 2
sid = 8
top = 1
bot = -1
cen = 0 0 0
rad = 1 1 1
axis= 2
if (exists(filnam)) then do
if (~open(state, filnam, 'R')) then break
if (readln(state) ~= version) then break
parse value readln(state) with seg sid top bot axis .
cen = readln(state)
rad = readln(state)
call close state
end
call req_begin sysnam
id_ax = req_addcontrol("Axis", 'c', 'X Y Z')
id_sid = req_addcontrol("Sides", 'n')
id_seg = req_addcontrol("Segments", 'n')
id_top = req_addcontrol("Top", 'n', 1)
id_bot = req_addcontrol("Bottom", 'n', 1)
id_rad = req_addcontrol("Radius", 'v', 1)
id_cen = req_addcontrol("Center", 'v', 1)
call req_setval id_ax, axis
call req_setval id_sid, sid, 8
call req_setval id_seg, seg, 2
call req_setval id_top, top, 1
call req_setval id_bot, bot, -1
call req_setval id_rad, rad, 1
call req_setval id_cen, cen, 0
if (~req_post()) then do
call req_end
exit
end
axis= req_getval(id_ax)
seg = req_getval(id_seg) % 1
sid = req_getval(id_sid) % 1
top = req_getval(id_top)
bot = req_getval(id_bot)
cen = req_getval(id_cen)
rad = req_getval(id_rad)
if (seg < 1) then seg = 1
if (sid < 3) then sid = 3
call req_end
/* Save state now, in case something fails.
*/
if (open(state, filnam, 'W')) then do
call writeln state, version
call writeln state, seg sid top bot axis
call writeln state, cen
call writeln state, rad
call close state
end
/* Prep
*/
rx = word(rad,1)
ry = word(rad,2)
cx = word(cen,1)
cy = word(cen,2)
totalpoints = sid * (seg+1)
totalcurves = seg + 1 + sid
call add_begin
call meter_begin totalpoints + totalcurves, sysnam
/* Create point rings.
*/
do i=0 to seg
z = (top - bot) * i / seg + bot
vl = ""
do j=0 to sid-1
a = 6.2832 * j / sid
x = rx * sin(a) + cx
y = ry * cos(a) + cy
vl = vl add_point(x y z)
call meter_step
end
vl = subword(vl,sid,1) vl subword(vl,1,2)
call add_curve vl, 'se'
call meter_step
end
do i = 1 to sid
vl = ""
do j = 0 to seg
vl = vl i+j*sid
end
call add_curve vl
call meter_step
end
call meter_end
call add_end
exit
syntax:
error:
t=Notify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
exit